package com.gmrz.uap.user;

import com.gmrz.uap.cfg.SystemConst;
import com.gmrz.uap.common.UAPSSOHelper;
import com.gmrz.uap.model.User;
import com.jfinal.aop.Interceptor;
import com.jfinal.aop.Invocation;

public class UserInterceptor implements Interceptor {
    public void intercept(Invocation invocation) {
        //User user = invocation.getController().getSessionAttr(SystemConst.SESSION_USER);
        User user = UAPSSOHelper.getUserByUapSessionId(invocation.getController().getRequest());

        if (user == null) {
            invocation.getController().redirect("/");
        } else {
            invocation.invoke();
        }
    }
}
